import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            StringBuilder sb = new StringBuilder();
            for (int j = 0; j < 8; j++) {
                sb.append(sc.nextLine());
            }
            String state = sb.toString();
            map.put(state, map.getOrDefault(state, 0) + 1);
            System.out.println(map.get(state));
        }
    }
}
